package leetcode;

/**
 * @Classname IsSubsequence_0392
 * @Author happytaohaha
 * @Date 2020/3/24
 * @Description 贪婪算法，每次将目标往前缩小一个
 */
public class IsSubsequence_0392 {
    public static boolean isSubsequence(String s, String t) {
        int len = t.length();
        int len2 = s.length();
        if(len2==0){
            return true;
        }
        int j = 0;
        for (int i = 0; i < len; i++) {
            if(t.charAt(i) == s.charAt(j)){
                j++;
            }
            if(j >= len2){
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isSubsequence("","ahbgdc"));
    }
}
